package com.ziyun.erp.web.modules.finance.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.ziyun.erp.common.utils.UserUtils;
import com.ziyun.erp.modules.order.entity.ErpOrderEntity;
import com.ziyun.erp.modules.order.service.ErpOrderService;
import com.ziyun.erp.modules.production.vo.ErpOrderProductionListVo;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用于订单物流以及外协成本审核
 *
 * @author llc
 * @email 
 * @date 2018-12-13 11:42:25
 */
@RestController
@RequestMapping("orderCost/erporder")
public class OrderCostController {
    @Autowired
    private ErpOrderService erpOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    /*@RequiresPermissions("orderCost:erporder:list")*/
    public R list(@RequestParam Map<String, Object> params){
        return erpOrderService.queryOrderCostPage(params);
    }

    @RequestMapping("/info/{orderNo}")
    public R info(@PathVariable("orderNo") String orderNo ){
        return erpOrderService.costOrderDetail(orderNo);
    }


    @RequestMapping("/batchAudit")
    public R batchAudit(@RequestParam("ids") String ids ){
        String createName=UserUtils.getCurentUser().getUsername();
        String createBy=UserUtils.getCurentUser().getUserId().toString();
        return   erpOrderService.batchAudit(ids,createName,createBy);
    }

    /**
     * 批量录入
     * @param ids
     * @return
     */
    @RequestMapping("/batchEnter")
    public R batchEnter(@RequestParam("ids") String ids ){
        String createName=UserUtils.getCurentUser().getUsername();
        String createBy=UserUtils.getCurentUser().getUserId().toString();
        return   erpOrderService.batchEnter(ids,createName,createBy);
    }

    @RequestMapping("/audit/{orderNo}")
    public R auditCost(@PathVariable("orderNo") String orderNo ){
        String createName=UserUtils.getCurentUser().getUsername();
        String createBy=UserUtils.getCurentUser().getUserId().toString();
        return   erpOrderService.auditCost(orderNo,createName,createBy);
    }

    @RequestMapping("/reBackStatus/{orderNo}")
    public R reBackStatus(@PathVariable("orderNo") String orderNo ){
        String createName=UserUtils.getCurentUser().getUsername();
        String createBy=UserUtils.getCurentUser().getUserId().toString();
        return   erpOrderService.reBackStatus(orderNo,createName,createBy);
    }
}
